# ！ /usr/bin/python3
# -*- coding:utf-8 -*-
# @Author:Peng Cao
# @File: staffCode_page.py
# @Software: PyCharm
from Common.plugs.basepage import BasePage
from Locators.StaffCodeLocators.staffCode_locators import StaffCodeLocators as loc
import allure
import time


class StaffCodePage(BasePage):
    """
    员工活码
    """

    def add_code(self, codeName: str, img: str):
        """
        新增员工活码
        :return:
        """
        doc = '员工活码列表页面_新增活码'
        with allure.step("step:点击新增"):
            self.click_element(locator=loc.code_add_btn, doc=doc)
        with allure.step("step:输入活码名称"):
            self.input_element(locator=loc.code_add_name, key=codeName, doc=doc)
        with allure.step("step:选择渠道"):
            self.select_option(locator=loc.code_channe, doc=doc)
            # 开启或关闭自动加好友
            # self.input_element(loc.user_add_dialog_password, password, doc)
            # 选择员工
            with allure.step("step：选择员工"):
                time.sleep(1)
                self.select_user(loc.code_select_user, doc)
            # 上传图片
            with allure.step("step：上传图片"):
                self.upload_img(loc.code_img_input, img, "上传图片")
                time.sleep(1)
            with allure.step("step：点击确定"):
                self.click_element(loc.code_create_btn, doc)
                # self.js_execute_script(loc.code_create_btn)
